<%@ Page Language="C#" MasterPageFile="~/site.master" AutoEventWireup="true" CodeFile="Project.aspx.cs" Inherits="Project" Title="Project" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:ObjectDataSource ID="odsProject" runat="server" DeleteMethod="Delete" InsertMethod="Insert"
        OldValuesParameterFormatString="original_{0}" SelectMethod="FetchByProjectTitle" TypeName="OpenProject.DataObjects.ProjectController"
        UpdateMethod="Update">
        <DeleteParameters>
            <asp:Parameter Name="ProjectId" Type="Object" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="ProjectId" Type="Int32" />
            <asp:Parameter Name="ProjectCode" Type="String" />
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="ProjectCode" Type="String" />
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:QueryStringParameter Name="ProjectTitle" QueryStringField="projectTitle" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:FormView ID="FormView1" runat="server" DataSourceID="odsProject">
        <EditItemTemplate>
            <asp:HiddenField ID="ProjectIdTextBox" runat="server" Value='<%# Bind("ProjectId") %>'>
            </asp:HiddenField>
            ProjectCode:
            <asp:TextBox ID="ProjectCodeTextBox" runat="server" Text='<%# Bind("ProjectCode") %>'>
            </asp:TextBox><br />
            Title:
            <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>'>
            </asp:TextBox><br />
            Description:
            <fck:FCKeditor id="txtContent" BasePath="~/FCKeditor/" ToolbarSet="OpenProject" runat="server" Value='<%# Bind("Description") %>'  Height="200" Width="400"/>
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                Text="Update">
            </asp:LinkButton>
            <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                Text="Cancel">
            </asp:LinkButton>
        </EditItemTemplate>
        <InsertItemTemplate>
            ProjectId:
            <asp:TextBox ID="ProjectIdTextBox" runat="server" Text='<%# Bind("ProjectId") %>'>
            </asp:TextBox><br />
            ProjectCode:
            <asp:TextBox ID="ProjectCodeTextBox" runat="server" Text='<%# Bind("ProjectCode") %>'>
            </asp:TextBox><br />
            Title:
            <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>'>
            </asp:TextBox><br />
            Description:
            <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'>
            </asp:TextBox><br />
            CMSPageRecords:
            <asp:TextBox ID="CMSPageRecordsTextBox" runat="server" Text='<%# Bind("CMSPageRecords") %>'>
            </asp:TextBox><br />
            WorkItemRecords:
            <asp:TextBox ID="WorkItemRecordsTextBox" runat="server" Text='<%# Bind("WorkItemRecords") %>'>
            </asp:TextBox><br />
            IsLoaded:
            <asp:CheckBox ID="IsLoadedCheckBox" runat="server" Checked='<%# Bind("IsLoaded") %>' /><br />
            IsNew:
            <asp:CheckBox ID="IsNewCheckBox" runat="server" Checked='<%# Bind("IsNew") %>' /><br />
            IsDirty:
            <asp:CheckBox ID="IsDirtyCheckBox" runat="server" Checked='<%# Bind("IsDirty") %>' /><br />
            TableName:
            <asp:TextBox ID="TableNameTextBox" runat="server" Text='<%# Bind("TableName") %>'>
            </asp:TextBox><br />
            ProviderName:
            <asp:TextBox ID="ProviderNameTextBox" runat="server" Text='<%# Bind("ProviderName") %>'>
            </asp:TextBox><br />
            NullExceptionMessage:
            <asp:TextBox ID="NullExceptionMessageTextBox" runat="server" Text='<%# Bind("NullExceptionMessage") %>'>
            </asp:TextBox><br />
            InvalidTypeExceptionMessage:
            <asp:TextBox ID="InvalidTypeExceptionMessageTextBox" runat="server" Text='<%# Bind("InvalidTypeExceptionMessage") %>'>
            </asp:TextBox><br />
            LengthExceptionMessage:
            <asp:TextBox ID="LengthExceptionMessageTextBox" runat="server" Text='<%# Bind("LengthExceptionMessage") %>'>
            </asp:TextBox><br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                Text="Insert">
            </asp:LinkButton>
            <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                Text="Cancel">
            </asp:LinkButton>
        </InsertItemTemplate>
        <ItemTemplate>
            <h2><%# Eval("Title") %></h2>
            Project Code:
            <asp:Label ID="ProjectCodeLabel" runat="server" Text='<%# Bind("ProjectCode") %>'>
            </asp:Label><br />
            <asp:literal ID="DescriptionLiteral" runat="server" Text='<%# Bind("Description") %>'>
            </asp:literal><br />
            <h3>Pages</h3>
            <p>
            There are <%# Eval("CMSPageRecords.Count") %> pages in this project:<br />
            <asp:repeater runat="server" DataSource='<%# Eval("CMSPageRecords") %>' ID="PagesRepeater">
                <ItemTemplate>
                    <a href='<%# UrlUtilities.PageUrl(ProjectTitle, Eval("PageUrl").ToString()) %>'><%# Eval("MenuTitle") %></a>
                </ItemTemplate>    
            </asp:repeater>
            </p>
            <h3>Work Items</h3>
            <p>
            There are <%# Eval("WorkItemRecords.Count")%> work items in this project:<br />
            <asp:repeater runat="server" DataSource='<%# Eval("WorkItemRecords") %>' ID="WorkItemsRepeater">
                <ItemTemplate>
                    <a href='<%# UrlUtilities.WorkItemUrl(ProjectTitle, Eval("WorkItemId").ToString())%>'><%# Eval("Title") %></a>
                </ItemTemplate>    
            </asp:repeater>
            </p>
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                Text="Edit">
            </asp:LinkButton>
            <asp:LinkButton ID="DeleteButton" OnClientClick="return(confirm('Are you sure you want to delete this project? You will not be able to undo this'))" runat="server" CausesValidation="False" CommandName="Delete"
                Text="Delete">
            </asp:LinkButton>
        </ItemTemplate>
    </asp:FormView>
   

</asp:Content>
